<?php

namespace Database\Seeders;

use App\Models\AdminUser;
use App\Models\Channel;
use App\Models\Merchant;
use App\Models\User;
use App\Models\UserMenu;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;

class DatabaseSeeder extends Seeder
{
    /**
     * Seed the application's database.
     *
     * @return void
     */
    public function run()
    {

        // // 创建默认通道
        $user = User::create([
            'username' => 'dora',
            'phone' => '12345678910',
            'email' => '12345678910@qq.com',
            'password' => Hash::make('12345678'),
            'avatar' => '',
        ]);
        Channel::create([
            'name' => '微信',
            'rate' => 20,
            'gateway' => Channel::GATEWAY_WECHAT,
            'method' => ['native', 'mp', 'mini'],
            'mch_id' => '商户id',
            'mch_key' => '商户key',
            'mp_appid' => '公众号appid',
            'mp_secret' => '公众号secret',
            'mini_appid' => '小程序appid',
            'mini_secret' => '小程序secret',
            'public_key' => null,
            'private_key' => null
        ]);
        Channel::create([
            'name' => 'QQ',
            'rate' => 20,
            'gateway' => Channel::GATEWAY_QQPAY,
            'method' => ['native'],
            'mch_id' => '商户id',
            'mch_key' => 'qq商户key',
            'mp_appid' => null,
            'mp_secret' => null,
            'public_key' => null,
            'private_key' => null
        ]);
        Channel::create([
            'name' => '支付宝',
            'rate' => 20,
            'gateway' => Channel::GATEWAY_ALIPAY,
            'method' => ['web', 'wap'],
            'mch_id' => '商户id',
            'mch_key' => null,
            'mp_appid' => null,
            'mp_secret' => null,
            'public_key' => '支付宝公钥',
            'private_key' => '应用私钥'
        ]);
        // 创建一个商户
        Merchant::create([
            'user_id' => $user->id,
            'client_id' => '150000',
            'client_secret' => '363192F2F256D6B0DCAF65360D77B46F',
        ]);
        // \App\Models\User::factory(10)->create();


        UserMenu::insert([
            [
                'title' => '用户中心',
                'url' => '/user/dashboard',
                'icon' => 'dashboard',
                'order' => 1
            ],
            [
                'title' => '我的商户',
                'url' => '/user/merchants',
                'icon' => 'merchants',
                'order' => 2
            ],
            [
                'title' => '我的订单',
                'url' => '/user/orders',
                'icon' => 'orders',
                'order' => 3,
            ],
            [
                'title' => '资金明细',
                'url' => '/user/balance-logs',
                'icon' => 'balance-logs',
                'order' => 4,
            ],
            [
                'title' => '提现记录',
                'url' => '/user/cash-draws',
                'icon' => 'cash-draws',
                'order' => 5,
            ],
            [
                'title' => '提现信息',
                'url' => '/user/cash-infos',
                'icon' => 'cash-infos',
                'order' => 6
            ]
        ]);

        // 创建默认管理员
        $user = AdminUser::create([
            'username' => 'dora',
            'phone' => '12345678910',
            'email' => '12345678910@qq.com',
            'password' => Hash::make('12345678'),
            'avatar' => '',
        ]);
    }
}
